from flask import Flask, request

import et
import wps
import wpp

app = Flask(__name__)


@app.route("/convert", methods=['post'])
def convert():
    if not request.get_json():
        return '{"status":"500"}'
    data = request.get_json()
    print(data)
    if data['type'] == 'wps':
        print(data['path'])
        wps.convert_to(data['path'], data['format'])
    elif data['type'] == 'et':
        print(data)
        et.convert_to(data['path'], data['format'])
    elif data['type'] == 'wpp':
        print(data)
        wpp.convert_to(data['path'], data['format'])
    else:
        return '{"status":"500"}'
    return '{"status":"200"}'


if __name__ == '__main__':
    app.run()
